/**
 * Created by chenzui on 2017/5/24.
 */
var $sendOffer = $('#send-offer');
var $wuliuCompany = $('#wuliuCompany');
var $wuliuNbr = $('#wuliuNbr');

function send(orderId) {
    var wuliuNbr = $wuliuNbr.val().trim();
    if(wuliuNbr == null || wuliuNbr == "" || wuliuNbr == undefined){
        alert("请填写物流单号");
        return;
    }
    var param = {
        id:orderId,
        wuliuCompany:$wuliuCompany.val().trim(),
        wuliuNbr:wuliuNbr
    }
    Ajax.ajax({
        url: "/order/send",
        data: param,
        type: "post",
        dataType: 'json',
        success:function(res){
            if (res.resultCode == 0) {
                alert("success");
                $wuliuCompany.attr("readonly","readonly");
                $wuliuNbr.attr("readonly","readonly");
                $sendOffer.val("修改");
            }else {
                alert(res.data);
            }
        }

    });
}
$(function () {
    debugger;
    $sendOffer.on('click',function () {
        var orderId = $(this).attr('date-order-id');
        var text = $(this).val();
        if(text == "发货"){
            send(orderId);
        }else {
            $wuliuCompany.removeAttr("readonly");
            $wuliuNbr.removeAttr("readonly");
            $sendOffer.val("发货");

        }
    });
})